""" 
Copyright 2009 Texas A&M University
 
Licensed under the Apache License, Version 2.0 (the "License"); you may not use 
this file except in compliance with the License. You may obtain a copy of the 
License at

http://www.apache.org/licenses/LICENSE-2.0
  
Unless required by applicable law or agreed to in writing, software distributed 
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
CONDITIONS OF ANY KIND, either express or implied. See the License for the 
specific language governing permissions and limitations under the License.
"""

from zope.interface import Interface
from zope.schema import Tuple, Choice, Bool
from zope.schema.vocabulary import SimpleVocabulary
from zope.i18nmessageid import MessageFactory



_ = MessageFactory('meercat.ui.plone')

sortFields = (
    (u'',u'Relevance'),
    (u'titleSortable',u'Title'),
    (u'creatorPrimarySortable',u'Author'),
    (u'datePublishedSortable',u'Publication Date'))

queryHandlers = (
    (u'dismax',u'Dismax'),
    (u'standard',u'Standard'))

class IMeercatSearch(Interface):
    filterQueries = Tuple(title=_(u'Filter Queries'),
                         description=_(u'Required filter queries that are '
                         'appended to the SOLR request.'))
    
    queryFields = Tuple(title=_(u'Query Fields'),
                       description=_(u'Query fields paramater (qf) passed to the '
                       'query handler when using a dismax type handler.'))
    
    defaultSortField = Choice(title=_(u'Default Sort Field'),
                              description=_(u'The default sort field for the '
                              'search. If not specified, defaults to whatever '
                              'the default is on the SOLR server'),
                              vocabulary=SimpleVocabulary.fromItems(sortFields))
    
    allowSortSelection = Bool(title=_(u'Allow sort selection'),
                              description=_(u''),
                              default=True)
    
    queryHandler = Choice(title=_(u'SOLR Query Handler'),
                          description=_(u'The SOLR2 query handler to use for the '
                          'search.'),
                          vocabulary=SimpleVocabulary.fromItems(queryHandlers))
    
    def getMeercatManager(self):
        """ Return an object that implements the 
        meercat.ui.plone.interfaces.IMeercatConnectionManager interface """
    
    def getQueryParameters(self):
        """ Return a dictionary of the query parameters """
    
    